From ae3e4d2c6a982636a7889627bf806c20e3e13f57 Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Tue, 11 May 2010 11:19:23 +0100 Subject: [PATCH] Define ABS() library function. Use it. Signed-off-by: Keir Fraser --- xen/common/compat/memory.c | 2 +- xen/include/xen/lib.h | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/xen/common/compat/memory.c b/xen/common/compat/memory.c index 4acbf7447a..2402984f1e 100644 --- a/xen/common/compat/memory.c +++ b/xen/common/compat/memory.c @@ -116,7 +116,7 @@ int compat_memory_op(unsigned int cmd, XEN_GUEST_HANDLE(void) compat) start_extent = cmp.xchg.nr_exchanged; end_extent = (COMPAT_ARG_XLAT_SIZE - sizeof(*nat.xchg)) / - (((1U << __builtin_abs(order_delta)) + 1) * + (((1U << ABS(order_delta)) + 1) * sizeof(*space)); if ( end_extent == 0 ) { diff --git a/xen/include/xen/lib.h b/xen/include/xen/lib.h index 45fc60f857..e09929a604 100644 --- a/xen/include/xen/lib.h +++ b/xen/include/xen/lib.h @@ -40,6 +40,11 @@ do { \ #define ASSERT(p) ((void)0) #endif +#define ABS(_x) ({ \ + typeof(_x) __x = (_x); \ + (__x < 0) ? -__x : __x; \ +}) + #define SWAP(_a, _b) \ do { typeof(_a) _t = (_a); (_a) = (_b); (_b) = _t; } while ( 0 ) -- 2.30.2